# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[self._obs = []
self._wdb = peewee_dbus
self._wymts = self._wdb.reference('com.wyplay.wymts', '/com/wyplay/wymts', 'com.wyplay.wymts')
self._wymts_sig = self._wdb.instance('/com/wyplay/wymts')
self._wymts_sig.signal('Connected', 's', self.connected, 0)
self._wymts_sig.signal('Disconnected', 's', self.disconnected, 0)
self._IsConnected = self._wymts.method('IsConnected', 's', 'b')
self._current_mode = 'mtp_off'
self._task_control = Task(self._set_control)
self.startup()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb764fcec>}
nname: 94
n 94(None)[]:
	i: 61(), 93()
	o: 

nname: 93
n 93(None)[]:
	i: 55(f)
	o: 94()

nname: 61
n 61(None)[self._task_control.args = ('mtp_on',)
self._task_control.start(0)
]:
	i: 55(t)
	o: 94()

nname: 55
n 55(mtp)[]:
	i: 3(), 22(), 54(AE)
	o: 61(t), 93(f)

nname: 22
n 22(None)[log.error('Error while calling IsConnected')
PRINT_EXCEPTION()
mtp = False
]:
	i: 0(except)
	o: 55()

nname: 3
n 3(None)[mtp = self._IsConnected('MTP')
]:
	i: 0(try)
	o: 55()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 22(except)

nname: 94
n 94(None)[]:
	i: 22()
	o: 

nname: 22
n 22(None)[except:
	log.error('Error while calling IsConnected')
	PRINT_EXCEPTION()
	mtp = False
if mtp:
	self._task_control.args = ('mtp_on',)
	self._task_control.start(0)
]:
	i: 0()
	o: 94()

nname: 0
n 0(None)[try:
	mtp = self._IsConnected('MTP')
]:
	i: 
	o: 22()

nname: 94
n 94(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	mtp = self._IsConnected('MTP')
except:
	log.error('Error while calling IsConnected')
	PRINT_EXCEPTION()
	mtp = False
if mtp:
	self._task_control.args = ('mtp_on',)
	self._task_control.start(0)
]:
	i: 
	o: 94()

nname: 0
n 0(None)[try:
	mtp = self._IsConnected('MTP')
except:
	log.error('Error while calling IsConnected')
	PRINT_EXCEPTION()
	mtp = False
if mtp:
	self._task_control.args = ('mtp_on',)
	self._task_control.start(0)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb764f98c>}
nname: 0
n 0(None)[log.debug('%s registred', obs)
self._obs.append(obs)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb764f24c>}
nname: 0
n 0(None)[self._obs.remove(obj)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb764f30c>}
nname: 165
n 165(None)[]:
	i: 15(AL), 144(), 148()
	o: 

nname: 148
n 148(None)[log.debug('current_mode == wanted_mode == %s: nothing to do', mode)
]:
	i: 0(f)
	o: 165()

nname: 144
n 144(None)[]:
	i: 66(AF), 141()
	o: 165()

nname: 141
n 141(None)[]:
	i: 118(AE)
	o: 144()

nname: 118
n 118(None)[log.debug('calling %s failled', obs)
continue
]:
	i: 76(except), 82()
	o: 141(AE)

nname: 82
n 82(None)[obs(mode, rcu, standby)
log.debug('%s called', obs)
continue
]:
	i: 76(try)
	o: 118()

nname: 76
n 76(None)[for obs in self._obs:
]:
	i: 66(for)
	o: 82(try), 118(except)

nname: 66
n 66(None)[]:
	i: 15(loop)
	o: 76(for), 144(AF)

nname: 15
n 15(None)[self._current_mode = mode
rcu, standby = mode_dict[mode]
log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
]:
	i: 0(t)
	o: 66(loop), 165(AL)

nname: 0
n 0(mode != self._current_mode)[]:
	i: 
	o: 15(t), 148(f)

nname: 165
n 165(None)[]:
	i: 15(AL), 148(), 66(AF), 118(AE)
	o: 

nname: 148
n 148(None)[log.debug('current_mode == wanted_mode == %s: nothing to do', mode)
]:
	i: 0(f)
	o: 165()

nname: 118
n 118(None)[except:
	log.debug('calling %s failled', obs)
	continue
]:
	i: 76()
	o: 165(AE)

nname: 76
n 76(None)[for obs in self._obs:
try:
	obs(mode, rcu, standby)
	log.debug('%s called', obs)
	continue
]:
	i: 66(for)
	o: 118()

nname: 66
n 66(None)[]:
	i: 15(loop)
	o: 76(for), 165(AF)

nname: 15
n 15(None)[self._current_mode = mode
rcu, standby = mode_dict[mode]
log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
]:
	i: 0(t)
	o: 66(loop), 165(AL)

nname: 0
n 0(mode != self._current_mode)[]:
	i: 
	o: 15(t), 148(f)

nname: 165
n 165(None)[]:
	i: 15(AL), 148(), 66(AF), 76(AE)
	o: 

nname: 148
n 148(None)[log.debug('current_mode == wanted_mode == %s: nothing to do', mode)
]:
	i: 0(f)
	o: 165()

nname: 76
n 76(None)[for obs in self._obs:
try:
	obs(mode, rcu, standby)
	log.debug('%s called', obs)
	continue
except:
	log.debug('calling %s failled', obs)
	continue
]:
	i: 66(for)
	o: 165(AE)

nname: 66
n 66(None)[]:
	i: 15(loop)
	o: 76(for), 165(AF)

nname: 15
n 15(None)[self._current_mode = mode
rcu, standby = mode_dict[mode]
log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
]:
	i: 0(t)
	o: 66(loop), 165(AL)

nname: 0
n 0(mode != self._current_mode)[]:
	i: 
	o: 15(t), 148(f)

nname: 165
n 165(None)[]:
	i: 148(), 76(AE)
	o: 

nname: 148
n 148(None)[log.debug('current_mode == wanted_mode == %s: nothing to do', mode)
]:
	i: 0(f)
	o: 165()

nname: 76
n 76(None)[for obs in self._obs:
	try:
		obs(mode, rcu, standby)
		log.debug('%s called', obs)
		continue
	except:
		log.debug('calling %s failled', obs)
		continue
]:
	i: 15(for)
	o: 165(AE)

nname: 15
n 15(None)[self._current_mode = mode
rcu, standby = mode_dict[mode]
log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
]:
	i: 0(t)
	o: 76(for)

nname: 0
n 0(mode != self._current_mode)[]:
	i: 
	o: 15(t), 148(f)

nname: 165
n 165(None)[]:
	i: 148(), 15(AE)
	o: 

nname: 148
n 148(None)[log.debug('current_mode == wanted_mode == %s: nothing to do', mode)
]:
	i: 0(f)
	o: 165()

nname: 15
n 15(None)[self._current_mode = mode
rcu, standby = mode_dict[mode]
log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
for obs in self._obs:
	try:
		obs(mode, rcu, standby)
		log.debug('%s called', obs)
		continue
	except:
		log.debug('calling %s failled', obs)
		continue
]:
	i: 0(t)
	o: 165(AE)

nname: 0
n 0(mode != self._current_mode)[]:
	i: 
	o: 15(t), 148(f)

nname: 165
n 165(None)[]:
	i: 0(AE)
	o: 

nname: 0
n 0(None)[if mode != self._current_mode:
	self._current_mode = mode
	rcu, standby = mode_dict[mode]
	log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
	for obs in self._obs:
		try:
			obs(mode, rcu, standby)
			log.debug('%s called', obs)
			continue
		except:
			log.debug('calling %s failled', obs)
			continue
else:
	log.debug('current_mode == wanted_mode == %s: nothing to do', mode)
]:
	i: 
	o: 165(AE)

self.nodes: {0: <unpyclib.structure.node instance at 0xb765804c>, 165: <unpyclib.structure.node instance at 0xb764f8ec>}
nname: 88
n 88(None)[return None
]:
	i: 60(), 71()
	o: 

nname: 71
n 71(None)[log.warn('no handler for %s', handler)
]:
	i: 0(f)
	o: 88()

nname: 60
n 60(None)[ref()
]:
	i: 0(t)
	o: 88()

nname: 0
n 0(ref)[log.debug('sig connected(%s) received', mode)
handler = '_' + mode.lower() + '_connect'
ref = getattr(self, handler, None)
]:
	i: 
	o: 60(t), 71(f)

nname: 0
n 0(None)[log.debug('sig connected(%s) received', mode)
handler = '_' + mode.lower() + '_connect'
ref = getattr(self, handler, None)
if ref:
	ref()
else:
	log.warn('no handler for %s', handler)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7658fcc>}
nname: 88
n 88(None)[return None
]:
	i: 60(), 71()
	o: 

nname: 71
n 71(None)[log.warn('no handler for %s', handler)
]:
	i: 0(f)
	o: 88()

nname: 60
n 60(None)[ref()
]:
	i: 0(t)
	o: 88()

nname: 0
n 0(ref)[log.debug('sig disconnected(%s) received', mode)
handler = '_' + mode.lower() + '_disconnect'
ref = getattr(self, handler, None)
]:
	i: 
	o: 60(t), 71(f)

nname: 0
n 0(None)[log.debug('sig disconnected(%s) received', mode)
handler = '_' + mode.lower() + '_disconnect'
ref = getattr(self, handler, None)
if ref:
	ref()
else:
	log.warn('no handler for %s', handler)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7658dac>}
nname: 0
n 0(None)[log.debug('MTP connect')
self._task_control.args = ('mtp_on',)
self._task_control.start(2)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb765848c>}
nname: 0
n 0(None)[log.debug('MTP disconnect')
self._task_control.args = ('mtp_off',)
self._task_control.start(2)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb765834c>}
nname: 6
n 6(None)[__doc__ = ' Main class to manage control mode (mtp / pygui / dms) '
__metaclass__ = MetaSingleton
def __init__(self):
	self._obs = []
	self._wdb = peewee_dbus
	self._wymts = self._wdb.reference('com.wyplay.wymts', '/com/wyplay/wymts', 'com.wyplay.wymts')
	self._wymts_sig = self._wdb.instance('/com/wyplay/wymts')
	self._wymts_sig.signal('Connected', 's', self.connected, 0)
	self._wymts_sig.signal('Disconnected', 's', self.disconnected, 0)
	self._IsConnected = self._wymts.method('IsConnected', 's', 'b')
	self._current_mode = 'mtp_off'
	self._task_control = Task(self._set_control)
	self.startup()

def startup(self):
	try:
		mtp = self._IsConnected('MTP')
	except:
		log.error('Error while calling IsConnected')
		PRINT_EXCEPTION()
		mtp = False
	if mtp:
		self._task_control.args = ('mtp_on',)
		self._task_control.start(0)

def register_observer(self, obs):
	log.debug('%s registred', obs)
	self._obs.append(obs)

def unregister_observer(self, obj):
	self._obs.remove(obj)

def _set_control(self, mode):
	if mode != self._current_mode:
		self._current_mode = mode
		rcu, standby = mode_dict[mode]
		log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
		for obs in self._obs:
			try:
				obs(mode, rcu, standby)
				log.debug('%s called', obs)
				continue
			except:
				log.debug('calling %s failled', obs)
				continue
	else:
		log.debug('current_mode == wanted_mode == %s: nothing to do', mode)

def connected(self, mode):
	log.debug('sig connected(%s) received', mode)
	handler = '_' + mode.lower() + '_connect'
	ref = getattr(self, handler, None)
	if ref:
		ref()
	else:
		log.warn('no handler for %s', handler)
	return None

def disconnected(self, mode):
	log.debug('sig disconnected(%s) received', mode)
	handler = '_' + mode.lower() + '_disconnect'
	ref = getattr(self, handler, None)
	if ref:
		ref()
	else:
		log.warn('no handler for %s', handler)
	return None

def _mtp_connect(self):
	log.debug('MTP connect')
	self._task_control.args = ('mtp_on',)
	self._task_control.start(2)

def _mtp_disconnect(self):
	log.debug('MTP disconnect')
	self._task_control.args = ('mtp_off',)
	self._task_control.start(2)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7646dac>}
nname: 204
n 204(None)[]:
	i: 168(), 203()
	o: 

nname: 203
n 203(None)[]:
	i: 0(f)
	o: 204()

nname: 168
n 168(None)[ctrl = ControlModeManager()
import pdb
pdb.set_trace()
]:
	i: 0(t)
	o: 204()

nname: 0
n 0(__name__ == '__main__')[from __future__ import absolute_import
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from peewee.misc_utils import MetaSingleton
from peewee.notifier import Task
from peewee.dbus import peewee_dbus
log = GET_LOGGER(__name__)
mode_dict = {'mtp_on': (False, True), 'mtp_off': (True, False)}
class ControlModeManager(object):
	__doc__ = ' Main class to manage control mode (mtp / pygui / dms) '
	__metaclass__ = MetaSingleton
	def __init__(self):
		self._obs = []
		self._wdb = peewee_dbus
		self._wymts = self._wdb.reference('com.wyplay.wymts', '/com/wyplay/wymts', 'com.wyplay.wymts')
		self._wymts_sig = self._wdb.instance('/com/wyplay/wymts')
		self._wymts_sig.signal('Connected', 's', self.connected, 0)
		self._wymts_sig.signal('Disconnected', 's', self.disconnected, 0)
		self._IsConnected = self._wymts.method('IsConnected', 's', 'b')
		self._current_mode = 'mtp_off'
		self._task_control = Task(self._set_control)
		self.startup()

	def startup(self):
		try:
			mtp = self._IsConnected('MTP')
		except:
			log.error('Error while calling IsConnected')
			PRINT_EXCEPTION()
			mtp = False
		if mtp:
			self._task_control.args = ('mtp_on',)
			self._task_control.start(0)

	def register_observer(self, obs):
		log.debug('%s registred', obs)
		self._obs.append(obs)

	def unregister_observer(self, obj):
		self._obs.remove(obj)

	def _set_control(self, mode):
		if mode != self._current_mode:
			self._current_mode = mode
			rcu, standby = mode_dict[mode]
			log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
			for obs in self._obs:
				try:
					obs(mode, rcu, standby)
					log.debug('%s called', obs)
					continue
				except:
					log.debug('calling %s failled', obs)
					continue
		else:
			log.debug('current_mode == wanted_mode == %s: nothing to do', mode)

	def connected(self, mode):
		log.debug('sig connected(%s) received', mode)
		handler = '_' + mode.lower() + '_connect'
		ref = getattr(self, handler, None)
		if ref:
			ref()
		else:
			log.warn('no handler for %s', handler)
		return None

	def disconnected(self, mode):
		log.debug('sig disconnected(%s) received', mode)
		handler = '_' + mode.lower() + '_disconnect'
		ref = getattr(self, handler, None)
		if ref:
			ref()
		else:
			log.warn('no handler for %s', handler)
		return None

	def _mtp_connect(self):
		log.debug('MTP connect')
		self._task_control.args = ('mtp_on',)
		self._task_control.start(2)

	def _mtp_disconnect(self):
		log.debug('MTP disconnect')
		self._task_control.args = ('mtp_off',)
		self._task_control.start(2)



]:
	i: 
	o: 168(t), 203(f)

nname: 0
n 0(None)[from __future__ import absolute_import
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from peewee.misc_utils import MetaSingleton
from peewee.notifier import Task
from peewee.dbus import peewee_dbus
log = GET_LOGGER(__name__)
mode_dict = {'mtp_on': (False, True), 'mtp_off': (True, False)}
class ControlModeManager(object):
	__doc__ = ' Main class to manage control mode (mtp / pygui / dms) '
	__metaclass__ = MetaSingleton
	def __init__(self):
		self._obs = []
		self._wdb = peewee_dbus
		self._wymts = self._wdb.reference('com.wyplay.wymts', '/com/wyplay/wymts', 'com.wyplay.wymts')
		self._wymts_sig = self._wdb.instance('/com/wyplay/wymts')
		self._wymts_sig.signal('Connected', 's', self.connected, 0)
		self._wymts_sig.signal('Disconnected', 's', self.disconnected, 0)
		self._IsConnected = self._wymts.method('IsConnected', 's', 'b')
		self._current_mode = 'mtp_off'
		self._task_control = Task(self._set_control)
		self.startup()

	def startup(self):
		try:
			mtp = self._IsConnected('MTP')
		except:
			log.error('Error while calling IsConnected')
			PRINT_EXCEPTION()
			mtp = False
		if mtp:
			self._task_control.args = ('mtp_on',)
			self._task_control.start(0)

	def register_observer(self, obs):
		log.debug('%s registred', obs)
		self._obs.append(obs)

	def unregister_observer(self, obj):
		self._obs.remove(obj)

	def _set_control(self, mode):
		if mode != self._current_mode:
			self._current_mode = mode
			rcu, standby = mode_dict[mode]
			log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
			for obs in self._obs:
				try:
					obs(mode, rcu, standby)
					log.debug('%s called', obs)
					continue
				except:
					log.debug('calling %s failled', obs)
					continue
		else:
			log.debug('current_mode == wanted_mode == %s: nothing to do', mode)

	def connected(self, mode):
		log.debug('sig connected(%s) received', mode)
		handler = '_' + mode.lower() + '_connect'
		ref = getattr(self, handler, None)
		if ref:
			ref()
		else:
			log.warn('no handler for %s', handler)
		return None

	def disconnected(self, mode):
		log.debug('sig disconnected(%s) received', mode)
		handler = '_' + mode.lower() + '_disconnect'
		ref = getattr(self, handler, None)
		if ref:
			ref()
		else:
			log.warn('no handler for %s', handler)
		return None

	def _mtp_connect(self):
		log.debug('MTP connect')
		self._task_control.args = ('mtp_on',)
		self._task_control.start(2)

	def _mtp_disconnect(self):
		log.debug('MTP disconnect')
		self._task_control.args = ('mtp_off',)
		self._task_control.start(2)



if __name__ == '__main__':
	ctrl = ControlModeManager()
	import pdb
	pdb.set_trace()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76446ec>}
from __future__ import absolute_import
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from peewee.misc_utils import MetaSingleton
from peewee.notifier import Task
from peewee.dbus import peewee_dbus
log = GET_LOGGER(__name__)
mode_dict = {'mtp_on': (False, True), 'mtp_off': (True, False)}
class ControlModeManager(object):
	__doc__ = ' Main class to manage control mode (mtp / pygui / dms) '
	__metaclass__ = MetaSingleton
	def __init__(self):
		self._obs = []
		self._wdb = peewee_dbus
		self._wymts = self._wdb.reference('com.wyplay.wymts', '/com/wyplay/wymts', 'com.wyplay.wymts')
		self._wymts_sig = self._wdb.instance('/com/wyplay/wymts')
		self._wymts_sig.signal('Connected', 's', self.connected, 0)
		self._wymts_sig.signal('Disconnected', 's', self.disconnected, 0)
		self._IsConnected = self._wymts.method('IsConnected', 's', 'b')
		self._current_mode = 'mtp_off'
		self._task_control = Task(self._set_control)
		self.startup()

	def startup(self):
		try:
			mtp = self._IsConnected('MTP')
		except:
			log.error('Error while calling IsConnected')
			PRINT_EXCEPTION()
			mtp = False
		if mtp:
			self._task_control.args = ('mtp_on',)
			self._task_control.start(0)

	def register_observer(self, obs):
		log.debug('%s registred', obs)
		self._obs.append(obs)

	def unregister_observer(self, obj):
		self._obs.remove(obj)

	def _set_control(self, mode):
		if mode != self._current_mode:
			self._current_mode = mode
			rcu, standby = mode_dict[mode]
			log.debug('setting control: mode=%s rcu=%s standby=%s', mode, rcu, standby)
			for obs in self._obs:
				try:
					obs(mode, rcu, standby)
					log.debug('%s called', obs)
					continue
				except:
					log.debug('calling %s failled', obs)
					continue
		else:
			log.debug('current_mode == wanted_mode == %s: nothing to do', mode)

	def connected(self, mode):
		log.debug('sig connected(%s) received', mode)
		handler = '_' + mode.lower() + '_connect'
		ref = getattr(self, handler, None)
		if ref:
			ref()
		else:
			log.warn('no handler for %s', handler)
		return None

	def disconnected(self, mode):
		log.debug('sig disconnected(%s) received', mode)
		handler = '_' + mode.lower() + '_disconnect'
		ref = getattr(self, handler, None)
		if ref:
			ref()
		else:
			log.warn('no handler for %s', handler)
		return None

	def _mtp_connect(self):
		log.debug('MTP connect')
		self._task_control.args = ('mtp_on',)
		self._task_control.start(2)

	def _mtp_disconnect(self):
		log.debug('MTP disconnect')
		self._task_control.args = ('mtp_off',)
		self._task_control.start(2)



if __name__ == '__main__':
	ctrl = ControlModeManager()
	import pdb
	pdb.set_trace()
